Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

315
Visualizações
{"error":"unsupported_grant_type","error_description":"grant_type parameter is missing"} for Spotify API

Using Spotify Documentation for Client Credential Flow (https://developer.spotify.com/documentation/general/guides/authorization/client-credentials/)

I was able to create an API request in javascript:

function getoAuth () {
    const client_id = id;
    const client_secret = secret;
    fetch("https://accounts.spotify.com/api/token", {
        method: 'POST',
        headers: {
           'Content-type': 'application/x-www-form-urlencoded',
           'Authorization': 'Basic' + (client_id + ":" + client_secret).toString('base64')
        },
        form: {
            grant_type: 'client_credentials',
        },
        json: true
        
    })
  }

But I'm receiving the following error: {"error":"unsupported_grant_type","error_description":"grant_type parameter is missing"}

Why is this failing?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Check the fetch library docs, you have to pass the formdata through body field. https://developer.mozilla.org/en-US/docs/web/api/fetch

 fetch("https://accounts.spotify.com/api/token", {
        method: 'POST',
        headers: {
           'Content-type': 'application/x-www-form-urlencoded',
           'Authorization': 'Basic<>'
        },
        body: new URLSearchParams({
            'grant_type': 'client_credentials'
        }),
        json: true
        
    })

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda